package com.scm.util;

import lombok.AllArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName Page
 * @Description TODO
 * @Author Xu
 * @Date 2021/7/7 11:30
 * @Version 1.0
 **/
@AllArgsConstructor
public class Page {
    private int currentPage;
    private int pageSize;

    public int getFirst() {
        return (currentPage - 1) * pageSize;
    }

    public int getMax() {
        return pageSize;
    }

    public static Map<String ,Object> get(Integer currentPage, Integer pageSize){
        Page page = new Page(currentPage,pageSize);
        Map<String ,Object> params = new HashMap<>();
        params.put("first",page.getFirst());
        params.put("max",page.getMax());
        return params;
    }
}
